package com.nbsaas.boot.evaluate.rest.convert;

import com.nbsaas.boot.entity.evaluate.EvaluateReply;
import com.nbsaas.boot.evaluate.api.domain.response.EvaluateReplyResponse;

import com.nbsaas.boot.utils.BeanDataUtils;
import com.nbsaas.boot.rest.api.Converter;
import java.util.HashMap;
import java.util.Map;
/**
* 评价回复-实体对象转化成响应对象
*/

public class EvaluateReplyResponseConvert  implements Converter<EvaluateReplyResponse,EvaluateReply> {

    @Override
    public EvaluateReplyResponse convert(EvaluateReply source) {
        EvaluateReplyResponse  result = new  EvaluateReplyResponse();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getReplyType()!=null){
                    Map<Integer,String> ReplyTypeMap=new HashMap<>();
                        ReplyTypeMap.put(1,"商家回复");
                        ReplyTypeMap.put(2,"用户追评");
                        ReplyTypeMap.put(3,"用户回复");
                        ReplyTypeMap.put(4,"系统回复");
                    String label=  ReplyTypeMap.get(source.getReplyType());
                    result.setReplyTypeName(label);
                    }
                    result.setReplyType(source.getReplyType());
                    if(source.getParentReply()!=null){
                        result.setParentReply(source.getParentReply().getId());
                    }

                    try {
                        if(source.getReplyUser()!=null){
                            result.setReplyUserName(source.getReplyUser().getName());
                        }
                    } catch (Exception ignored) { }


                    try {
                        if(source.getTargetUser()!=null){
                            result.setTargetUserName(source.getTargetUser().getName());
                        }
                    } catch (Exception ignored) { }

                    if(source.getReplyUser()!=null){
                        result.setReplyUser(source.getReplyUser().getId());
                    }
                    if(source.getAnonymous()!=null){
                    Map<Integer,String> AnonymousMap=new HashMap<>();
                        AnonymousMap.put(0,"否");
                        AnonymousMap.put(1,"是");
                    String label=  AnonymousMap.get(source.getAnonymous());
                    result.setAnonymousName(label);
                    }
                    result.setAnonymous(source.getAnonymous());
                    if(source.getStoreState()!=null){
                        result.setStoreStateName(String.valueOf(source.getStoreState()));
                    }
                    if(source.getEvaluate()!=null){
                        result.setEvaluate(source.getEvaluate().getId());
                    }
                    if(source.getTargetUser()!=null){
                        result.setTargetUser(source.getTargetUser().getId());
                    }
        return result;
    }

}

